#coding=utf-8
from weixin import WeixinMP

from weixin.message import TemplateMessage

# wx = WeixinMp(appid='your_appid', appsecret='your_appsecret', token='your_token')
wx = WeixinMp(appid='wx0399c1855ef2cc2c', appsecret='9a14c4cc147dcbb2c26c124e39697eae', token='Yjw41022319920503')

# @wx.handler
# def handle_message(message):
#     if isinstance(message, TextMessage):
#         reply = TextMessage(content='你好，收到了你的消息: {}'.format(message.content))
#         wx.reply(reply)
# 创建模板消息对象
template_id = 'your_template_id'
user_openid = 'user_openid'
url = 'http://www.example.com'
data = {
    "first": {"value": "恭喜你中奖了！", "color": "#173177"},
    "keyword1": {"value": "小米手机", "color": "#173177"},
    "keyword2": {"value": "2014年1月1日", "color": "#173177"},
    "remark": {"value": "请尽快领取您的奖品！", "color": "#173177"}
}
message = TemplateMessage(template_id, user_openid, url, data)
# 发送模板消息
wx.send_template_message(message)